﻿@using SimpleScrum.Areas.Scrum.Models
@model IEnumerable<SimpleScrum.Core.Entities.Team>
@{
    ViewBag.Title = "Team";
    var usersModel = new UsersModel();
    var teamModel = new TeamModel();
    var teamMemberModel = new TeamMemberModel();
}
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li class="active">
            <i class="icon-home home-icon"></i>
            @ViewBag.Title
        </li>
    </ul>
    <div class="nav-search pull-right">
        <a class="btn btn-small btn-success" href="@Url.Action("New","Team")">
            <i class="icon-plus-sign-alt"></i> New Team
        </a>
    </div>
</div>
<div class="page-content">
    <div class="page-header position-relative">
        <h1>@ViewBag.Title<small><i class="icon-double-angle-right"></i>overview and settings</small></h1>
    </div><!--/.page-header-->
    @if (Model.Count().CompareTo(0) == 0)
    {
        <div class="row-fluid">
            <div class=" span10 offset1 text-center">
                <h1 class="text-error">You didn't create any Team!</h1>
                <h2 class="text-success">Create Your First Team</h2>
                <a class="btn btn-app btn-success" href="@Url.Action("New", "Team")">
                    <i class="icon-plus-sign-alt"></i> New<br/>Team
                </a>
            </div>
        </div>
    }
    else
    {
        <div class="row-fluid">
            <div class="span12">
                <!--PAGE CONTENT BEGINS-->
                @foreach (var team in Model)
                {
                    var memberList = teamMemberModel.GetUsersByTeamId(team.Id);
                    <div>
                        <h1 class="green">@Html.DisplayFor(modelTeam => team.Name)</h1>
                        @Html.ActionLink("Add Member", "AddMember", "Team", new {@Team = team, @class = "btn btn-info"})
                        @foreach (var members in memberList)
                        {
                            var user = usersModel.GetUsersById(members.Users.Id);
                            <h2>@Html.DisplayFor(modelTeamMember => user.Email)</h2>
                        }
                    </div>
                }
            </div>
        </div>
    }
</div>
